using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace DacTaHinhThuc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("setting.xml");

            XmlNodeList nodes = doc.GetElementsByTagName("GroupKeyword");

            string strKeyword = "";
            string strColor = "";

            int i;
            for (i = 0; i < nodes.Count; i++)
            {
                strKeyword = nodes[i]["Keyword"].InnerText.ToLower();
                strColor = nodes[i]["Color"].InnerText;
            }

            string[] list = { "," };
            string[] listKeyword = strKeyword.Split(list, StringSplitOptions.RemoveEmptyEntries);


            textBoxInput.SetValueKeyword(listKeyword, strColor);            

            textBoxInput.HightLightAllSentences();
        }

        private void menuOpen_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //do sth
            }
        }

        //private void button1_Click(object sender, EventArgs e)
        //{
        //    //ColorDialog cd = new ColorDialog();

        //    //if (cd.ShowDialog() == DialogResult.OK)
        //    //{
        //    //    MessageBox.Show(cd.Color.Name);

        //    //    Color color = new Color();
        //    //    color = Color.f
        //    //}

        //    Color c = Color.Red;

        //    Color c1 = Color.FromName("Red");

        //    if (c == c1)
        //    {
        //        MessageBox.Show("OK");
        //    }

        //    MessageBox.Show(c.Name);
        //}

        private void settingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SettingFrm frm = new SettingFrm();
            frm.ColorKeyword = textBoxInput.ColorKeyword.Name;
            frm.ShowDialog();
            textBoxInput.ColorKeyword = Color.FromName(frm.ColorKeyword);
        }

    }
}